<?php

class spDialog2 extends spDiv
{
	static public function create( $param )
	{
		$param = array_merge(
			array(
				"title"				=> "",
				"roundedCorners"	=> true,
				"buttons"			=> array(),		// class, content
				"data"				=> array(),
				"use_submit"		=> false
			),
			$param
		);
		
		$classDialog = "spDialogStatic";
		$classTitle = "spTitle";
		
		if ( $param["roundedCorners"] )
		{
			$classDialog.= " spRounded";
			$classTitle	 .= " spTitleBlack";
		}
	
		$container = new spDiv(array(
			"class" => $classDialog
		));
		$title = new spDiv(array(
			"class"		=> $classTitle,
			"content" 	=> $param["title"]
		));
		$container->addChild( $title );

		if ( count($param["buttons"]) )
		{
			foreach ( $param["buttons"] as $b )
			{
				$class = isset($b["class"])?$b["class"]:"";
			
				if ( $param["use_submit"] )
				{
					$but = new spInput(array(
						"class" => "spDialogButton",
						"type" => "submit",
						"name" => $b["name"],
						"value" => $b["value"]
					));
				}
				else
				{
					$but = new spAnchor(array(
						"class" 	=> "spDialogButton ".$class,
						"href" 		=> "",
						"content" 	=> "(".$b["content"].")",
						"attr"		=> $param["data"]
					));
				}
				$container->addChild( $but );
			}
		}

		$container->addChild( new spClearBoth );
		
		return $container;
	}
	
	static public function createFieldSet( $title )
	{
		$fs = new spFieldSet(array(
			"class" => "spFieldSet"
		));
		$fs->addChild( new spLegend(array(
			"content" => $title
		)));
				
		return $fs;
	}
}


?>